<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>generator函数学习</title>
</head>
<body>
	<script type="text/javascript">
		function* gen(x) {
		  console.log('start')
		  const y = yield x * 2
		  debugger
		  return y
		}

		const g = gen(1)
		g.next()   // start { value: 2, done: false }
		g.next(4)  // { value: 4, done: true }
	</script>
</body>
</html>